package com.masterlu.leetcode.daily.stack.simple;

/**
 * @date created in 2021/5/18 17:39
 */
public class S1544MakeGood {


    public String makeGood(String s) {

        StringBuilder builder = new StringBuilder();
        for (char c : s.toCharArray()) {

            int length = builder.length();
            if (length > 0 && (c + 32 == builder.charAt(length - 1)
                    || c - 32 == builder.charAt(length - 1))) {
                builder.setLength(length - 1);
            } else {
                builder.append(c);
            }

        }
        return builder.toString();
    }
}
